import util.TreeNode;

/**
 * Created by losor on 2017/3/15.
 */
public class _101_SymmetricTree {

    public static void main(String[] args) {
    }

    public boolean isSymmetric(TreeNode root) {
        if (root == null){
            return true;
        }
        return checkSymmetric(root.right,root.left);
    }

    public boolean checkSymmetric(TreeNode left,TreeNode right){
        if (left == null && right == null){
            return true;
        }
        else if(left == null || right == null){
            return false;
        }
        if (left.val == right.val){
            return checkSymmetric(left.right,right.left) && checkSymmetric(right.right,left.left);
        }
        else{
            return false;
        }
    }
}
